package com.wenx.camel;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.http.common.HttpMessage;

import javax.servlet.http.HttpServletRequest;

public class reviveProcess implements Processor {

    public void process(Exchange exchng) throws Exception {
        System.out.println("==========================");
        String str = exchng.getIn().getBody(String.class);//获取post ：raw
        System.out.println(str);
        HttpServletRequest req = exchng.getIn(HttpMessage.class).getRequest();
        String name = req.getParameter("name"); //获取post ：form-data
        System.out.println(name);
//        exchng.getOut().removeHeaders("CamelHttp*"); //在process中也可以去掉 camle路由头信息
        exchng.getOut().setHeader(Exchange.HTTP_METHOD, "POST"); //指定请求的方式
        exchng.getOut().setBody(str);//camle 在路由时去掉了body参数，所以需要手动添加
//        exchng.getOut().setHeader(Exchange.HTTP_QUERY, "hl=en&test=activemq"); //指定请求参数
        // exchng.getOut().setBody("example.json-String.with中文。"); //重新设置body参数
    }

}
